package com.aaa.service.impl;

import com.aaa.common.domain.RentInContractInfo;
import com.aaa.common.query.PageQuery;
import com.aaa.common.query.RentInContractQuery;
import com.aaa.common.result.Result;
import com.aaa.mapper.RentInContractMapper;
import com.aaa.service.RentInContractService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: 宋文森
 * @Date: 2021/02/05/15:21
 * @Description:
 */
@Service
public class RentInContractServiceImpl implements RentInContractService {
    @Autowired
    private  RentInContractMapper rentInContractMapper;

    public Result listPublicAssetsRentInContract(PageQuery pageQuery) {
        Page<RentInContractInfo> rentInContractInfoPage = new Page<>(pageQuery.getCurrentPage(),pageQuery.getPageCount());
        Page<RentInContractInfo> rentInContractInfos = rentInContractMapper.listPublicAssetsRentInContract(rentInContractInfoPage);
        if (rentInContractInfos!=null){
            return Result.success(rentInContractInfos);
        }
        return Result.error("公有资产租入信息查询失败！");
    }

    public Result listOtherAssetsRentInContract(PageQuery pageQuery) {
        Page<RentInContractInfo> rentInContractInfoPage = new Page<>(pageQuery.getCurrentPage(),pageQuery.getPageCount());
        Page<RentInContractInfo> rentInContractInfos = rentInContractMapper.listOtherAssetsRentInContract(rentInContractInfoPage);
        if (rentInContractInfos!=null){
            return Result.success(rentInContractInfos);
        }
        return Result.error("其他资产租入信息查询失败！");
    }

    public Result publicOtherConditionalQuery(RentInContractQuery rentInContractQuery) {
        Page<RentInContractInfo> rentInContractInfoPage = new Page<>(rentInContractQuery.getCurrentPage(),rentInContractQuery.getPageCount());
        Page<RentInContractInfo> rentInContractInfos = rentInContractMapper.publicOtherConditionalQuery(rentInContractInfoPage, rentInContractQuery.getContractId(), rentInContractQuery.getLessor());
        if (rentInContractInfos!=null){
            return Result.success(rentInContractInfos);
        }
        return Result.error("公有资产租入信息条件查询失败！");
    }

    public Result OtherAssetsConditionalQuery(RentInContractQuery rentInContractQuery) {
        Page<RentInContractInfo> rentInContractInfoPage = new Page<>(rentInContractQuery.getCurrentPage(),rentInContractQuery.getPageCount());
        Page<RentInContractInfo> rentInContractInfos = rentInContractMapper.OtherAssetsConditionalQuery(rentInContractInfoPage, rentInContractQuery.getContractId(), rentInContractQuery.getLessor());
        if (rentInContractInfos!=null){
            return Result.success(rentInContractInfos);
        }
        return Result.error("其他资产租入信息条件查询失败！");

    }


}
